<div bsModal #createOrEditModal="bs-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="createOrEditModal"
    aria-hidden="true" [config]="{backdrop: 'static'}">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <form *ngIf="active" #editForm="ngForm" novalidate (ngSubmit)="save()" autocomplete="off">
                <div class="modal-header">
                    <h4 class="modal-title">
                        <span *ngIf="id">编辑人员工时</span>
                        <span *ngIf="!id">创建人员工时</span>
                    </h4>
                    <button type="button" class="close" (click)="close()" [attr.aria-label]="l('Close')">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>

                <div class="modal-body">

                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group taskwork">
                                    <p-dropdown
                                    [options]="pipes"
                                    name="pipe"
                                    filter="true"
                                    [(ngModel)]="pipe"
                                    placeholder="选择任务"
                                    optionLabel="displayText"
                                    (onChange)="changepipe()"
                                    [style]="{ width: '90%' }"
                                ></p-dropdown>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group taskwork">
                                    <p-dropdown
                                    [options]="nodes"
                                    name="node"
                                    filter="true"
                                    [(ngModel)]="node"
                                    placeholder="工序"
                                    optionLabel="displayText"
                                    (onChange)="showTaskWork()"
                                    [style]="{ width: '90%' }"
                                ></p-dropdown>
                            </div>
                        </div>
                    </div>

                    <div class="row" [busyIf]="primengTableHelper.isLoading">
                        <div class="col-md-12">
                            <p-table
                                [value]="nodeWorker"
                                [paginator]="true"
                                [rows]="10"
                            >
                                <ng-template pTemplate="caption">
                                    人员及工时分配
                                </ng-template>
                                <ng-template pTemplate="header">
                                    <tr>
                                        <th style="width:2em"></th>
                                        <th>人员姓名</th>
                                        <th>工时占比(%)</th>
                                        <th style="width:8em">编辑</th>
                                    </tr>
                                </ng-template>
                                <ng-template pTemplate="body" let-rowData let-ri="rowIndex">
                                    <tr>
                                        <td style="height: 36px;"></td>
                                        <td pEditableColumn>
                                            <p-cellEditor>
                                                <ng-template pTemplate="input">
                                                    <p-dropdown
                                                        [options]="users"
                                                        [(ngModel)]="rowData.userName"
                                                        [style]="{ width: '90%' }"
                                                        optionLabel="name"
                                                        name="uname"
                                                    ></p-dropdown>
                                                </ng-template>
                                                <ng-template pTemplate="output">
                                                    {{ rowData.userName.name }}
                                                </ng-template>
                                            </p-cellEditor>
                                        </td>
                                        <td pEditableColumn>
                                            <p-cellEditor>
                                                <ng-template pTemplate="input">
                                                    <p-spinner
                                                        size="35"
                                                        [(ngModel)]="
                                                            rowData.timePercentage
                                                        "
                                                        [min]="0"
                                                        [max]="100"
                                                        name="timePercentage"
                                                    ></p-spinner>
                                                </ng-template>
                                                <ng-template pTemplate="output">
                                                    {{ rowData.timePercentage }}
                                                </ng-template>
                                            </p-cellEditor>
                                        </td>
                                        <td style="text-align: center">
                                            <!-- <button pButton type="button" pInitEditbaleRow icon="pi pi-check" class="ui-button-success" style="margin-right: .5em" (click)="onRowEditSave(rowData)"></button> -->
                                            <button pButton type="button" pInitEditbaleRow icon="pi pi-times" class="ui-button-danger" (click)="onRowEditInit(ri)"></button>
                                        </td>
                                    </tr>
                                </ng-template>
                                <ng-template pTemplate="summary" let-rowData>
                                    <div style="text-align:left">
                                        <button
                                            type="button"
                                            pButton
                                            icon="fa fa-plus"
                                            (click)="showDialogToAdd()"
                                            label="新增"
                                        ></button>
                                        <button type="button"
                                        pButton
                                        icon="fa fa-save"
                                        (click)="save()"
                                        label="保存"
                                        style="margin-left:15px; background-color: #34bfa3; border:solid 1px #34bfa3;">
                                        </button>
                                    </div>
                                </ng-template>
                            </p-table>
                        </div>
                    </div>
                </div>

                <div class="modal-footer">
                    <button [disabled]="saving" type="button" class="btn btn-default" (click)="close()">{{l("Cancel")}}</button>

                </div>

            </form>

        </div>
    </div>
</div>
